package cn.itsource.fallback;

import cn.itsource.api.DriverRemoteApi;
import cn.itsource.result.JSONResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @program fccar_240420
 * @Description
 * @Date 2024/09/04 15:59
 * @Version 1.0
 */
@Component
public class DriverRemoteApiFallbackFactory implements FallbackFactory<DriverRemoteApi> {

    @Override
    public DriverRemoteApi create(Throwable cause) {
        return new DriverRemoteApi() {
            @Override
            public JSONResult getCancelAndComplaint() {
                return JSONResult.error(cause.getMessage());
            }
        };
    }
}
